﻿using System;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

using FLEN_Sim.funct;
using FLEN_Sim.gui.map;

using GMap.NET.WindowsForms;

namespace FLEN_Sim.containerobjects
{
    [Serializable()]

    /// <summary>
    /// Container-Klasse für ein Krankenhaus-Objekt.
    /// </summary>    
    public class Hospital : IFLENObject
    {
        private string id, shortid, adress, city;
        private short citynumber;
        private MapMarkers.HospitalMarker marker;
        private double lat, lon;

        /// <summary>
        /// Standard-Konstruktor.
        /// </summary>
        /// <param name="ID">Name des Krankenhauses</param>
        /// <param name="ShortID">gebräuchliche Abkürzung des Krankenhausnamens</param>
        /// <param name="Adress">Postanschrift des Krankenhauses</param>
        public Hospital(string ID, string ShortID, string Adress)
        {
            id = ID;
            shortid = ShortID;
            adress = Adress;

            city = adress.Split(',')[1].Remove(0,1);

            citynumber = CityNumbers.getCityByName(city);

            marker = new MapMarkers.HospitalMarker(GeoCoder.getLocationNominatim(adress, citynumber));
            marker.ToolTipMode = MarkerTooltipMode.OnMouseOver;
            marker.ToolTipText = id;

            lat = marker.Position.Lat;
            lon = marker.Position.Lng;
        }

        /// <summary>
        /// Standard-Konstruktor.
        /// </summary>
        /// <param name="ID">Name des Krankenhauses</param>
        /// <param name="ShortID">gebräuchliche Abkürzung des Krankenhausnamens</param>
        /// <param name="Adress">Postanschrift des Krankenhauses</param>
        /// <param name="Lat">Breitengrad</param>
        /// <param name="Lon">Längengrad</param>
        public Hospital(string ID, string ShortID, string Adress, double Lat, double Lon)
        {
            id = ID;
            shortid = ShortID;
            adress = Adress;

            city = adress.Split(',')[1].Remove(0, 1);

            citynumber = CityNumbers.getCityByName(city);

            lat = Lat;
            lon = Lon;

            marker = new MapMarkers.HospitalMarker(new GMap.NET.PointLatLng(lat, lon));
            marker.ToolTipMode = MarkerTooltipMode.OnMouseOver;
            marker.ToolTipText = id;
        }

        /// <summary>
        /// Gibt den Namen des Krankenhauses.
        /// </summary>
        public string ID
        {
            get
            {
                return id;
            }
        }

        /// <summary>
        /// Gibt die gebräuchliche Abkürzung des Krankenhauses zurück.
        /// </summary>
        public string ShortID
        {
            get
            {
                return shortid;
            }
        }

        /// <summary>
        /// Gibt die Anschrift des Krankenhauses zurück.
        /// </summary>
        public string Adress
        {
            get
            {
                return adress;
            }
        }

        /// <summary>
        /// Gibt die Stadt zurück, in der das Krankenhaus angesiedelt ist.
        /// </summary>
        public string City
        {
            get
            {
                return city;
            }
        }

        /// <summary>
        /// Gibt den Marker auf der Karte zurück.
        /// </summary>
        public MapMarkers.HospitalMarker Marker
        {
            get
            {
                return marker;
            }
        }
    }
}
